<template>
  <div class="C_CSSZ_XTCSSZ">
    <div class="title">
      系统初始化
    </div>
    <div class="query">
      创建日期：
      <el-date-picker
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        :picker-options="pickerOptions"
        size="small"
      >
      </el-date-picker>
      <el-button
        size="small"
        icon="el-icon-search"
        type="primary"
        style="margin-left:5px"
        >搜索</el-button
      >
      <el-button
        size="small"
        icon="el-icon-plus"
        type="primary"
        style="margin-left:5px"
        @click="open('add')"
        >新建</el-button
      >
    </div>
    <div class="main">
      <el-table
        :data="tableData"
        border
        height="700"
        style="width: 100%"
        :header-cell-style="{
          background: 'rgb(246,250,253)',
          color: '#000000',
        }"
      >
        <el-table-column prop="date" label="编码" width="160">
        </el-table-column>
        <el-table-column prop="address" label="名称" width="180">
        </el-table-column>
        <el-table-column prop="address" label="数值" width="80">
        </el-table-column>
        <el-table-column prop="address" label="描述"> </el-table-column>
        <el-table-column prop="address" label="类别" width="120">
        </el-table-column>
        <el-table-column prop="address" label="外联编码" width="120">
        </el-table-column>
        <el-table-column prop="address" label="创建日期" width="180">
        </el-table-column>
        <el-table-column prop="name" label="状态" width="80" align="center">
          <template slot-scope="scope">
            <el-tag type="success" effect="dark" size="mini">
              {{ scope.row.name }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button
              type="text"
              icon="el-icon-remove-outline"
              title="停用"
            ></el-button>
            <el-button
              type="text"
              icon="el-icon-edit"
              title="编辑"
              @click="open('edit', scope.row)"
            ></el-button>
            <el-button
              type="text"
              icon="el-icon-delete"
              title="删除"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="text-align:center;margin-top:5px">
        <el-pagination layout="prev, pager, next" :total="50"> </el-pagination>
      </div>
    </div>
    <!-- 弹层 -->
    <el-dialog
      :title="titleText"
      :visible.sync="dialogVisible"
      width="55%"
      :before-close="handleClose"
      :append-to-body="true"
      :close-on-click-modal="false"
    >
      <el-form
        label-position="right"
        label-width="150px"
        :model="formLabelAlign"
      >
        <el-form-item label="编码：">
          <el-input v-model="formLabelAlign.name"></el-input>
        </el-form-item>
        <el-form-item label="名称：">
          <el-input v-model="formLabelAlign.region"></el-input>
        </el-form-item>
        <el-form-item label="数值：">
          <el-input v-model="formLabelAlign.region"></el-input>
        </el-form-item>
        <el-form-item label="描述：">
          <el-input
            v-model="formLabelAlign.type"
            type="textarea"
            :rows="4"
          ></el-input>
        </el-form-item>
        <el-form-item label="类别：">
          <el-input v-model="formLabelAlign.type"></el-input>
        </el-form-item>
        <el-form-item label="外联编码：">
          <el-input v-model="formLabelAlign.type"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: "",
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "已启用",
          address: " 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "已启用",
          address: " 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "已启用",
          address: " 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "已启用",
          address: " 1516 弄",
        },
      ],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      formLabelAlign: {},
      dialogVisible: false,
      titleText: "",
      tableData_a: [
        {
          date: "测试数据测试数据",
          address: "123",
        },
      ],
      codes: [],
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
    };
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {},
  /**
   * el 被新创建的 vm.el 替换，并挂载到实例上去之后调用该钩子。
   * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.el 也在文档内。
   */
  mounted() {},
  // 组件方法
  methods: {
    open(flag, val) {
      if (flag == "add") {
        this.titleText = "新增字典类型维护";
      }
      if (flag == "edit") {
        this.titleText = "编辑字典类型维护";
      }
      if (val) {
      }
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
    },
    handleSelectionChange(val) {
      this.codes = val;
    },
    addPlus() {
      this.tableData_a.push({ date: "", address: "" });
    },
    del_row() {
      var that = this;
      this.codes.forEach((item) => {
        that.tableData_a.forEach((item2, index) => {
          if (item.address == item2.address) {
            this.tableData_a.splice(index, 1);
          }
        });
      });
    },
  },
};
</script>

<style scoped lang="scss">
.C_CSSZ_XTCSSZ {
  .title {
    background-color: rgb(233, 242, 255);
    line-height: 45px;
    font-size: 18px;
    font-weight: 700;
    padding: 0 10px;
  }
  .query {
    margin: 0 10px;
    margin-top: 10px;
    padding: 5px;
    border: 1px solid #ccc;
    line-height: 40px;
  }
  .main {
    padding: 0 10px;
    margin-top: 10px;
  }
  .input_style {
    display: inline-block;
    width: 200px;
  }
}
</style>
